package com.ruoyi.energy.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.energy.domain.TcParkingLease;
import com.ruoyi.energy.service.ITcParkingLeaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 车位租赁Controller
 *
 * @author cjie
 * @date 2021-07-29
 */
@Api(tags = " 车位租赁--已经废弃")
@RestController
@RequestMapping("/tcParkingLease")
public class TcParkingLeaseController extends BaseController {
    @Autowired
    private ITcParkingLeaseService tcParkingLeaseService;

    /**
     * 查询车位租赁列表
     */
    @ApiOperation(value="查询车位租赁列表", notes="查询车位租赁列表")
    @PreAuthorize(hasPermi = "energy:tcParkingLease:list")
    @GetMapping("/list")
    public TableDataInfo list(TcParkingLease tcParkingLease) {
        startPage();
        List<TcParkingLease> list = tcParkingLeaseService.selectTcParkingLeaseList(tcParkingLease);
        return getDataTable(list);
    }

    /**
     * 导出车位租赁列表
     */
    @ApiOperation(value="导出车位租赁列表", notes="导出车位租赁列表")
    @PreAuthorize(hasPermi = "energy:tcParkingLease:export")
    @Log(title = "车位租赁", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TcParkingLease tcParkingLease) throws IOException {
        List<TcParkingLease> list = tcParkingLeaseService.selectTcParkingLeaseList(tcParkingLease);
        ExcelUtil<TcParkingLease> util = new ExcelUtil<TcParkingLease>(TcParkingLease.class);
        util.exportExcel(response, list, "车位租赁数据");
    }
    /**
     * 获取车位租赁详细信息
     */
    @ApiOperation(value="获取车位租赁详细信息", notes="获取车位租赁详细信息")
    @PreAuthorize(hasPermi = "energy:tcParkingLease:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(tcParkingLeaseService.selectTcParkingLeaseById(id));
    }

    /**
     * 新增车位租赁
     */
    @ApiOperation(value="新增车位租赁", notes="新增车位租赁")
    @PreAuthorize(hasPermi = "energy:tcParkingLease:add")
    @Log(title = "车位租赁", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TcParkingLease tcParkingLease) {
        return toAjax(tcParkingLeaseService.insertTcParkingLease(tcParkingLease));
    }

    /**
     * 修改车位租赁
     */
    @ApiOperation(value="修改车位租赁", notes="修改车位租赁")
    @PreAuthorize(hasPermi = "energy:tcParkingLease:edit")
    @Log(title = "车位租赁", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TcParkingLease tcParkingLease) {
        return toAjax(tcParkingLeaseService.updateTcParkingLease(tcParkingLease));
    }

    /**
     * 删除车位租赁
     */
    @ApiOperation(value="删除车位租赁", notes="删除车位租赁")
    @ApiImplicitParam(name = "ids", value = "车位租赁ID数组", required = true,paramType = "path", allowMultiple=true, dataType = "String")
    @PreAuthorize(hasPermi = "energy:tcParkingLease:remove")
    @Log(title = "车位租赁", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(tcParkingLeaseService.deleteTcParkingLeaseByIds(ids));
    }
}
